package com.feicheng.house.service.impl;

import com.feicheng.house.entity.Menjin;
import com.feicheng.house.mapper.MenjinMapper;
import com.feicheng.house.result.ResultInfo;
import com.feicheng.house.service.IMenjinService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import org.aspectj.weaver.patterns.ThisOrTargetAnnotationPointcut;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author feichengTech
 * @since 2021-11-05
 */
/**
 * 门禁基本信息增上改查
 * @author Aqu
 *
 */
@Service
public class MenjinServiceImpl extends ServiceImpl<MenjinMapper, Menjin> implements IMenjinService {
	/**
	 * see.MenjinService.uodateInfo
	 */
	@Override
	public ResultInfo updateInfo(Menjin menjin) {
		// TODO Auto-generated method stub
		return ResultInfo.success(this.updateById(menjin));
	}
	
	/**
	 * see.MenjinService.addInfo
	 */
	@Override
	public ResultInfo addInfo(Menjin menjin) {
		// TODO Auto-generated method stub
		return ResultInfo.success(this.save(menjin));
	}
	
	/**
	 * see.MenjinService.deleteInfo
	 */
	@Override
	public ResultInfo deleteInfo(Integer menjinId) {
		// TODO Auto-generated method stub
		  QueryWrapper<Menjin> queryWrapper = new QueryWrapper<Menjin>();
		  queryWrapper.eq("menjin_id", menjinId);
		  Menjin menjin = this.getOne(queryWrapper);
		  menjin.setDeleteFlag(false);
		  return ResultInfo.success(this.update(menjin,queryWrapper));
	}
	
	/**
	 * see.MenjinService.selectInfo
	 */
	@Override
	public ResultInfo selectInfo(String searchKey, Integer currentInteger, Integer sizeInteger) {
		// TODO Auto-generated method stub
		 QueryWrapper<Menjin> queryWrapper = new QueryWrapper<Menjin>();
		  queryWrapper.eq("delete_flag", true);
		  if (StringUtils.hasLength(searchKey)) {
		   queryWrapper.and(Wrapper ->Wrapper.like("menjin_id", searchKey))
									   .or().like("menjinxinghao", searchKey)
									   .or().like("uid", searchKey);
		  } 
		  IPage<Menjin> pageInfo = new Page<Menjin>(currentInteger,sizeInteger);

		  return ResultInfo.success(this.page(pageInfo, queryWrapper));
		 }
	
	/**
	 * see.MenjinService.selectOneInfo
	 */
	@Override
	public ResultInfo selectOneInfo(Integer menjinId) {
		// TODO Auto-generated method stub
		QueryWrapper<Menjin> queryWrapper = new QueryWrapper<Menjin>();
		queryWrapper.eq("menjin_id", menjinId);
		
		return ResultInfo.success(this.getOne(queryWrapper));
	}
	/**
	 * see.MenjinService.selectList
	 */
	@Override
	 public ResultInfo selectList() {
	  // TODO Auto-generated method stub
	  QueryWrapper<Menjin> queryWrapper = new QueryWrapper<>();
	  queryWrapper.eq("delete_flag", true);
	  return ResultInfo.success(this.list(queryWrapper));
	  }
	
	
	
	}


